package com.example.findmystuff;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class SearchActivity extends Activity {

	Button nameButton,categoryButton,statusButton,dateButton,matchButton,homeButton;
	/**
	 * This method is called when the activity is created
	 * @param savedInstanceState a bundle used to save the state that this instance of the activity is in.
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search);
		
		nameButton = (Button) findViewById(R.id.nameButton);
		categoryButton = (Button) findViewById(R.id.categoryButton);
		statusButton = (Button) findViewById(R.id.statusButton);
		dateButton = (Button) findViewById(R.id.dateButton);
		matchButton = (Button) findViewById(R.id.matchButton);
		homeButton = (Button) findViewById(R.id.homeButton);

		
        nameButton.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent i = new Intent(SearchActivity.this, SearchNameActivity.class);
						startActivity(i);
					}
				});
        
        categoryButton.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent i = new Intent(SearchActivity.this, SearchCategoryActivity.class);
						startActivity(i);
					}
				});
        
        statusButton.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent i = new Intent(SearchActivity.this, SearchStatusActivity.class);
						startActivity(i);
					}
				});
        
        dateButton.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent i = new Intent(SearchActivity.this, SearchDateActivity.class);
						startActivity(i);
					}
				});
        
        matchButton.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent i = new Intent(SearchActivity.this, MatchItemsActivity.class);
						startActivity(i);
					}
				});	
			
		homeButton.setOnClickListener(
        		new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if(MainActivity.loggedUser.equals("admin")){
							Intent i = new Intent(SearchActivity.this, AdminHomeActivity.class);
							startActivity(i);
						}
						else{
							Intent i = new Intent(SearchActivity.this, HomeActivity.class);
							startActivity(i);
						}
					}
				});
	}
	/**
	 * Initializes the contents of the Activity's standard options menu.
	 * @param menu the standard options menu
	 */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_search, menu);
		return true;
	}

}
